<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark" th:fragment="header">
    <div class="container">
        <a class="navbar-brand" href="/">电影网站</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav me-auto">
                <li class="nav-item">
                    <a class="nav-link" href="/movie/ranking/weekly">周榜</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/movie/ranking/monthly">月榜</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/movie/ranking/all">总榜</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/movie/ranking/rating">评分榜</a>
                </li>
            </ul>
            <form class="d-flex" action="/movie/search" method="get">
                <div class="input-group">
                    <input class="form-control" type="search" name="keyword" th:value="${keyword}" placeholder="搜索电影名称、导演、演员">
                    <button class="btn btn-outline-light" type="submit">搜索</button>
                    <a href="/movie/search" class="btn btn-outline-light ms-2" title="高级搜索"><i class="bi bi-funnel"></i> 高级筛选</a>
                </div>
            </form>
            <ul class="navbar-nav ms-3">
                <li class="nav-item" th:if="${session.user == null}">
                    <a class="nav-link" href="/login">登录</a>
                </li>
                <li class="nav-item" th:if="${session.user == null}">
                    <a class="nav-link" href="/register">注册</a>
                </li>
                <li class="nav-item dropdown" th:if="${session.user != null}">
                <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown">
                    <span th:text="${session.user.username}"></span>
                    <!-- 导航栏VIP状态显示 -->
                    <span class="badge bg-warning" th:if="${session.user.isVip}">VIP</span>
                </a>
                    <ul class="dropdown-menu">
                        <!-- VIP状态显示 -->
                        <li th:if="${session.user != null and session.user.isVip}">
                            <div class="dropdown-item-text p-3 bg-light">
                                <h6 class="fw-bold text-primary">VIP会员</h6>
                                <p class="mb-1">有效期至：<span th:text="${#dates.format(session.user.vipExpireTime, 'yyyy-MM-dd')}"></span></p>
                                <div class="progress mt-2" style="height: 6px;">
                                </div>

                            </div>
                        </li>
                        <li><a class="dropdown-item" href="/order/vip" th:if="${session.user == null or !session.user.isVip}">开通VIP</a></li>
                        <li><a class="dropdown-item" href="/order/orders">我的订单</a></li>
                        <li><hr class="dropdown-divider"></li>
                        <li><a class="dropdown-item" href="/logout">退出登录</a></li>
                    </ul>

                </li>
            </ul>
        </div>
    </div>
</nav>
</body>
</html>